package com.bole.controller;

import com.bole.data.Result;
import com.bole.dto.permission.AdminDto;
import com.bole.feign.AdminFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin")
public class AdminController {

    @Autowired
    private AdminFeign adminFeign;

    @GetMapping
    public Result get() {
        return adminFeign.get();
    }

    @PostMapping
    public Result add(@RequestParam Long rid, @RequestBody AdminDto admin) {
        return adminFeign.add(rid, admin);
    }

    @PutMapping("/{id}")
    public Result update(@PathVariable("id") Long id, @RequestParam Long rid, @RequestBody AdminDto admin) {
        return adminFeign.updateById(id, rid, admin);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") Long id){
        return adminFeign.deleteById(id);
    }
}
